home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dskut / 525td.zip / SAMPLE2.BAT < prev    next >
DOS Batch File  |  1992-03-10  |  7KB  |  192 lines

  1. echo off
  2. cls
  3. echo.
  4. echo.
  5. echo           SAMPLE2.BAT
  6. echo.
  7. echo.
  8.  
  9. rem
  10. rem
  11. rem     This batch file demonstrates how a batch file can be used
  12. rem     to perform TAPE commands. With this batch file, commands
  13. rem     that are required for advanced backup operations are demonstrated,
  14. rem     including:
  15. rem 
  16. rem         Tape retensioning
  17. rem         Appended backups
  18. rem         Volume names and search labels assigned to each backup
  19. rem         Errorlevel checking
  20. rem
  21. rem     This batch file will perform a selective backup of the drive or
  22. rem     drives specified as the parameter in the command line.  For example, 
  23. rem     if the following is entered from the DOS command line:
  24. rem
  25. rem         SAMPLE2 C: D:
  26. rem
  27. rem     then complete selective backups of drives C: and D: will be performed.
  28. rem     Also, the batch file will record a log of the tape operations and 
  29. rem     their results in the file TAPELOG.
  30. rem
  31. rem     This file uses certain DOS batch file commands, such as replaceable
  32. rem     parameters and IF statements.  Refer to your DOS Reference Manual
  33. rem     for more on batch files and batch file commands.
  34. rem
  35. rem     This file will also use the UTL and SBK tape commands and some of 
  36. rem     their parameters.  Refer to the Mountain FileSafe TAPE Software User's
  37. rem     Guide for more on these commands.
  38. rem
  39.  
  40. rem
  41. rem     First, we need to check to see if the user entered any drive
  42. rem     identifiers from the DOS command line.  If not, then we will go 
  43. rem     to a section that will display the usage instructions.
  44. rem
  45.  
  46. if "%1"=="" goto usage
  47.  
  48. rem     Okay, so let's start with the backup of the first specified drive.
  49. rem     First, before we start the first backup, let's retension the tape.
  50. rem
  51. rem     NOTE: The retension command is not necessary for the 1200 
  52. rem     series drives and is therefore an unavailable option.
  53.  
  54. echo.                                                              >TAPELOG
  55. echo Retensioning tapes.                                          >>TAPELOG
  56. echo.                                                             >>TAPELOG
  57.  
  58.  
  59. TAPE UTL T
  60.  
  61. rem     Next, let's backup the first specified drive. We're using the
  62. rem     following parameters to the SBK (Selective Backup) command:
  63. rem
  64. rem         %1          - The parameter that contains the drive designator.
  65. rem
  66. rem         \/S         = Backup all files starting at root and 
  67. rem                       include all subdirectories.
  68. rem
  69. rem         /V          = After backup, read files from tape and disk, 
  70. rem                       and verify them.
  71. rem
  72. rem         /C+         = Do not pause for the Overwrite warning. Also, 
  73. rem                       continue after certain file errors are encountered.
  74. rem
  75. rem                       Any files that cannot be opened or read will be 
  76. rem                       skipped and noted within SKIPLIST.TXT.
  77. rem
  78. rem         /P-S-I-R    = Disable prompting for system files (S), hidden or
  79. rem                       invisible files (I), and read-only files (R).
  80. rem     
  81. rem         /NDrive-%1  = Assign a name to the backup volume. The name
  82. rem                       is "Drive-" followed by the drive designator.
  83. rem                       For example, "Drive-C:".
  84. rem     
  85. rem         /LDrive-%1  = Assign a unique label for volume searching. The 
  86. rem                       label is "Drive-" followed by the drive designator.
  87. rem                       For example, "Drive-C:".
  88. rem
  89.  
  90. echo.                                                             >>TAPELOG
  91. echo Backing up drive %1.                                         >>TAPELOG
  92. echo Volume label = Drive-%1                                      >>TAPELOG
  93. echo.                                                             >>TAPELOG
  94.  
  95. TAPE SBK %1\/S /V /C+ /P-S-I-R /N Drive-%1 /L Drive-%1
  96.  
  97. rem
  98. rem     Next, let's check the result of the tape operation.  If an error
  99. rem     occurred, then an errorlevel will be set and can be queried from this
  100. rem     batch file.
  101. rem
  102.  
  103. if errorlevel 5 goto error5
  104. if errorlevel 4 goto error4
  105. if errorlevel 3 goto error3
  106. if errorlevel 2 goto error2
  107. if errorlevel 1 goto error1
  108.  
  109. :next
  110. rem
  111. rem     Next, let's backup all of the other drives specified on the DOS
  112. rem     command line.  First, check to see if there are any other drives
  113. rem     entered.  If nothing is left to back up, then we will exit.
  114. rem
  115.  
  116. shift
  117. if "%1" == "" goto end
  118.  
  119. rem     Okay, so we've got another drive to backup.  So, we'll back up this
  120. rem     drive in the same way that we did before.  However, we will perform
  121. rem     an appended backup and will use the /A parameter to do this.
  122. rem
  123.  
  124. echo.                                                             >>TAPELOG
  125. echo Backing up drive %1.                                         >>TAPELOG
  126. echo Volume label = Drive-%1                                      >>TAPELOG
  127. echo.                                                             >>TAPELOG
  128.  
  129. TAPE SBK %1\/S /V /C+ /P-S-I-R /A /N Drive-%1 /L Drive-%1
  130.  
  131. if errorlevel 5 goto error5
  132. if errorlevel 4 goto error4
  133. if errorlevel 3 goto error3
  134. if errorlevel 2 goto error2
  135. if errorlevel 1 goto error1
  136. goto next
  137.  
  138. :error1
  139. echo No files found to backup.                                    >>TAPELOG
  140. goto next
  141.  
  142. :error2
  143. echo Some files have not been backed up due to file sharing       >>TAPELOG
  144. echo conflicts.  The following is the list of files that          >>TAPELOG
  145. echo have been skipped.                                           >>TAPELOG
  146. echo.                                                             >>TAPELOG
  147. TYPE %1\SKIPLIST.TXT                                              >>TAPELOG
  148. echo.                                                             >>TAPELOG
  149. echo Backing up files that have been modified since last backup.  >>TAPELOG
  150.  
  151. TAPE SBK %1\/S /V /C+ /P-S-I-R /A /M /NDrive-%1 (Modified Files) /LDrive-%1 (Modified)
  152. if errorlevel 5 goto error5
  153. if errorlevel 4 goto error4
  154. if errorlevel 3 goto error3
  155. if errorlevel 2 goto mod_error
  156. if errorlevel 1 goto error1
  157. goto next
  158.  
  159. :mod_error
  160. echo Some files still cannot be backed up due to file sharing     >>TAPELOG
  161. echo conflicts.  The following is the list of files that          >>TAPELOG
  162. echo have been skipped.                                           >>TAPELOG
  163. echo.                                                             >>TAPELOG
  164. TYPE %1\SKIPLIST.TXT                                              >>TAPELOG
  165. echo.                                                             >>TAPELOG
  166. goto next
  167.  
  168. :error3
  169. echo Tape command terminated by user.                             >>TAPELOG
  170. goto end
  171.  
  172. :error4
  173. echo Tape command terminated due to internal error.               >>TAPELOG
  174. goto end
  175.  
  176. :error5
  177. echo Trouble creating SKIPLIST.TXT or TAPE_DTE.DAT.              >>TAPELOG
  178. echo Some files have been skipped.                               >>TAPELOG
  179. goto next
  180.  
  181. :usage
  182. echo   Usage: SAMPLE2 d:   
  183. echo          where d: is the identifier of the drive that will be
  184. echo          backed up. More than one drive can be specified for backup.
  185. echo.
  186. echo    Example:    SAMPLE2 C: D: X:
  187. echo.
  188. echo.
  189.  
  190. :end
  191. 
  192.